package net.child.chess;

import android.app.Activity;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import net.child.chess.core.Board;
import net.child.chess.gui.BoardView;
import net.child.chess.gui.PuzzleSpinner;
import android.widget.LinearLayout;
import android.widget.Button;

public class ChessActivity extends Activity 
{
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        
        LinearLayout.LayoutParams layoutParam =
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT );
        
        int displayWidth = getWindowManager().getDefaultDisplay().getWidth();
        Board board = new Board();
        BoardView boardView = new BoardView(this, board, displayWidth);  
        PuzzleSpinner puzzleSpinner = new PuzzleSpinner(this, boardView);
        Button randomizeButton = new Button(this);
        randomizeButton.setText("Randomize Puzzle");
        randomizeButton.setLayoutParams(layoutParam);
        randomizeButton.setOnClickListener(puzzleSpinner);
        
        LinearLayout layout = new LinearLayout(this);
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.addView(boardView);
        layout.addView(puzzleSpinner);
        layout.addView(randomizeButton);
        
        this.addContentView(layout, layoutParam);
    }
}